<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-title">
          <h5>会员分类添加</h5>
          <div class="ibox-tools">
            <button type="button" class="btn btn-xs btn-primary btn-back-reply"><i class="fa fa-reply"></i> 返回</button>
          </div>
        </div>
        <div class="ibox-content">
          <form class="form-horizontal" method="post" action="#{$smarty.const.ACT}#/admin/ShopType/shop_type_add/">
            <div class="form-group">
              <label class="col-sm-2 control-label">分类名称</label>
              <div class="col-sm-10">
                <input name="typename" class="form-control" type="text" placeholder="请输入会员分类名称" required/>
                <span class="help-block m-b-none"></span> </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">排序</label>
              <div class="col-sm-10">
                <input name="sort" class="form-control" type="text" placeholder="请输入排序" required/>
                <span class="help-block m-b-none"></span> </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">启用</label>
              <div class="col-sm-8">
                <div class="checkbox i-checks">
                  <input type="checkbox" name="visible" value="1" checked/>
                </div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">简介</label>
              <div class="col-sm-10">
                <textarea name="intro" class="form-control" cols="80" rows="2">#{$one.description}#</textarea>
                <span class="help-block m-b-none"></span> </div>
            </div>
            <div class="ibox-content">
              <table class="table" id="type_dist_table">
                <thead>
                  <tr>
                    <th width="50">下级层数设置只能为数字不能重复</th>
                    <th width="50">层数提成比例</th>
                    <th width="10">操作</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td><input type="text" name="layers[]" class="form-control" value="0"></td>
                    <td><input type="text" name="rate[]" class="form-control" value="0"></td>
                    <td><a href="#" onclick="delTr(this);" >删除</a></td>
                  </tr>
                </tbody>
              </table>
						说明：这里的返现设置为本组会员是享受返现下级层数和所在层数享受的比例,0层表示会员本身消费提成
            </div>
            <div class="ibox-content">
              <button id="add_dist_btn" type="button" class="btn  btn-primary"><i class='fa fa-plus'></i> 增加一个属性</button>
            </div>
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <button class="btn  btn-w-m btn-info" type="submit">保存数据</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
$(document).ready(function () {
	$('.i-checks').iCheck({
		checkboxClass: 'icheckbox_square-green',
		radioClass: 'iradio_square-green',
	});
  $("#add_dist_btn").click(function(){	
	  var html= $("#type_dist_table tbody tr:last").clone(true);
	  var ind = $("#type_dist_table tbody tr:last >td:first").find('input').val();
     $("#type_dist_table tbody").append(html);
	  $("#type_dist_table tbody tr:last >td:first").find('input').val(Number(ind)+1);
  });	
});
function delTr(obj){
	var trlen = $("#attr_value_table tbody tr").length;
	if(trlen==1){
		alert('Cannot Be Deleted');
		return false;
	}
	$(obj).parent().parent().remove(); 
}

function set_attr_value(obj){	
	//
	input=$(obj).parent().prev().find('input').val();
	span =$(obj).parent().prev().find('span').html('我来是设置的');
	alert(input);
	return false;
}
</script>
</body>
</html>